<template>
	<view class="v-home-page" :style="{ '--bg-image': `url(${ materialBg})` }">
		<view :style="{ height: navTop + 'px' }"></view>

		<view class="flex-start-center margin-bottom_40rpx" style="color:#333333" @click="navback()">

			<uni-icons style="margin-top: 7rpx; " color="#333333" type="left" size="20"></uni-icons>
			<text style="color: 333333;font-size: 33rpx;"> 购买记录</text>
		</view>
		<sunui-navbar :items="tabList" lineHeight="80rpx" :isCenter="true" :currentIndex="navIndex" padding="20rpx"
			activeColor="#000000" :size="340" activeLineBg="#000000" textAlign="center" activeLineWidth="23%"
			activeDirection="center" activeLineHeight="4rpx" bgColor="transparent" @change="getChange"></sunui-navbar>



		<mescroll-body ref="mescrollRef " @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback"
			@up="upCallback">
			<view class="withdrawalList" v-for="(item,index) in memberLogList">
				<view class="padding-bottom_20rpx flex-between border-bottom-f7f7f7">
					<view class=" flex-columns">




						<view class="flex-columns">
							<view class=" flex-start-center">
								<view class=" font-weight_bold font-overflow" style="font-size: 30rpx;width: 300rpx;">
									{{item.name}}
								</view>

							</view>
							<view class="  font-size_24rpx margin-top_20rpx">
								获得:{{item.point}}(算力)
							</view>
						</view>

					</view>
					<view class="flex-column-end">
						<view class="font-weight_bold" style="color: rgb(255, 0, 0);font-size: 30rpx;">
							{{item.type==1?'支付'+item.money+'元':'卡密激活'}}
						</view>
						<view class="margin-top_16rpx margin-top_20rpx" style="color: #999999;">

						</view>
					</view>
				</view>
				<view class="margin-top_20rpx flex-start-center" style="color: #999999;">

					<text style="font-size: 25rpx;margin-bottom: 5rpx;">购买时间：{{item.create_time}}</text>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				navTop: '',
				materialBg: 'https://tuanma.weijuyunke.com/index/images/material.png',
				navIndex: 0,
				tabList: [{
					name: '包月套餐',
					id: '1' //null
				}, {
					name: '加油包',
					id: '2' //null
				}, ],
				memberLogList:[]

			}
		},
		onLoad() {
			const app = getApp();
			this.navTop = app.globalData.navTop;



		},
		computed: {


		},
		methods: {
			navback(){
				this.$sun.navBack()
			},
			getChange(e) {
				console.log(e)
				this.navIndex = e

				this.$nextTick(() => {
					this.mescroll?.resetUpScroll();
				})



			},
			async upCallback(scroll) {

				const result = await this.$http.get({
					url: this.navIndex == 0?this.$api.memberLog:this.$api.packageLog,
					data: {
						// 用户id
						uid: uni.getStorageSync('uid'),

						page: scroll.num,
						psize: 10,




					}
				});
				if (result.errno == 0) {

					this.mescroll.endByPage(result.data.list.length, result.totalPage);
					if (scroll.num == 1) this.memberLogList = [];
					this.memberLogList = this.memberLogList.concat(result.data.list);

					console.log(this.memberLogList)

				}
			},


		}
	}
</script>

<style lang="less">
	.v-home-page {
		// background-image: (var(--bg-image));
		background-repeat: no-repeat;
		background-size: cover;
		position: relative;
		height: 100vh;
		padding: 20rpx;
		background-color: #F9F8FF;

		.withdrawalList {


			border-radius: 20rpx;

			background: rgb(255, 255, 255);
			padding: 30rpx 30rpx;

			margin-top: 40rpx;

			.imgIcon {
				width: 75.78rpx;
				height: 75.78rpx;
				margin-right: 15rpx;
				border-radius: 50%;
			}

			.green {
				border-radius: 8rpx;
				min-width: 156rpx;
				max-width: 190rpx;
				padding: 10rpx;
				background: rgba(9, 186, 7, 0.1);
				color: rgb(49, 169, 82);

			}

			.blue {
				border-radius: 8rpx;
				width: 92rpx;
				height: 38rpx;
				background: #F5F5F5;
				color: #999999;
				margin-left: 15rpx;
			}

			.red {
				border-radius: 8rpx;
				width: 92rpx;
				height: 38rpx;
				background: #FF2B2B;
				color: #fff;
				margin-left: 15rpx;
			}
		}
	}
</style>